package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum ModuleService {
    SYSTEM_ADMIN("erp-admin", "后台-系统管理服务"),
    SYSTEM_BASIC("erp-basic", "后台-基础信息服务"),
    SYSTEM_CONFIG("erp-config", "后台-配置管理服务"),
    SYSTEM_INVENTORY("erp-inventory", "后台-出入库管理服务"),
    LINSEN_GATEWAY("linsen-gateway", "网关服务"),
    LINSEN_UAA("linsen-uaa", "认证服务"),
    LINSEN_OSS("linsen-oss", "文件上传服务"),
    ;

    @JsonValue
    private String value;
    private String description;

    private static final Map<String, ModuleService> VALUES = new HashMap<>();

    static {
        for (final ModuleService moduleService : ModuleService.values()) {
            ModuleService.VALUES.put(moduleService.getValue(), moduleService);
        }
    }

    @JsonCreator
    public static ModuleService getByValue(String value) {
        return ModuleService.VALUES.get(value);
    }
}
